导航菜单
首页 >  The Bootstrap Image Responsive Approach  > Bootstrap 5 Approach Responsive

Bootstrap 5 Approach Responsive

Bootstrap 5 responsive approach ensures web page visibility across devices. Media queries, such as min-width and occasionally max-width, are used to address responsiveness. Efforts are made to minimize reliance on media queries while accommodating complex component needs.

Bootstrap 5 Approach Responsive:

MixinDescription@include media-breakpoint-only(md) { … }Executes code only when the screen size is ‘md’.@include media-breakpoint-between(md, xl) { … }Executes code when the screen size is between ‘md’ and ‘xl’.

Syntax:

// Min-width

@include media-breakpoint-up(sm) { ... }@include media-breakpoint-up(md) { ... }

// Max-width

@include media-breakpoint-down(lg) { ... }@include media-breakpoint-down(xl) { ... }

// Single-breakpoint

@include media-breakpoint-only(xxl) { ... }

// Between-breakpoint

@include media-breakpoint-between(md, xl) { ... }

Example 1: In this example we Bootstrap 5’s responsive approach using a media query to change text color within a container for viewport widths between 768px and 991.98px.

HTMLBootstrap 5 Approach Responsive@media (min-width: 768px) and (max-width: 991.98px) {.container {color: blue;}}Bootstrap 5 Approach ResponsiveGeeksforGeeks is a great platformto learn various skills likeHTML,CSS,Javascript and many more.

Output :

https://media.geeksforgeeks.org/wp-content/uploads/20240726170030/Bootstrap-approach-responsive.mp4

Example 2: In this example we demonstrates Bootstrap 5’s responsive approach using media queries to change text color within a container for different viewport widths: blue for 768px to 991.98px and green for 991.98px to 1199.98px.

HTMLBootstrap 5 Approach Responsive@media (min-width: 768px) and (max-width: 991.98px) {.container {color: blue;}}@media (min-width: 991.98px) and (max-width: 1199.98px) {.container {color: green;}}Bootstrap 5 Approach ResponsiveGeeksforGeeks is a great platformto learn various skills likeHTML,CSS,Javascript and many more.

Output:

https://media.geeksforgeeks.org/wp-content/uploads/20240726170133/bootstrap-approach-responsive.mp4

H

harshil123NewsImprove Next ArticleBootstrap 5 Approach Classes

相关推荐: